package com.lenovo.uitest.base;

import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.core.UiWatcher;

public class WATCH {

	public void watch10086(){
		String s10086="查询帐单请拨10086.*";
		final UiObject checkObject=new UiObject(new UiSelector().textMatches(s10086));
		final UiObject ok=new UiObject(new UiSelector().textMatches("OK|确定"));
		UiDevice.getInstance().registerWatcher("10086", new UiWatcher() {
			
			@Override
			public boolean checkForCondition() {
				if (checkObject.exists()) {
					try {
						ok.click();
						return true;
					} catch (UiObjectNotFoundException e) {
						e.printStackTrace();
					}					
				}
				return false;
			}
		});
	}
	
	
}
